package com.manager.core.pl190.host668

import android.app.Activity
import android.util.Log
import com.baidu.mobads.sdk.api.MobRewardVideoActivity
import com.bykv.vk.openvk.stub.activity.Stub_Standard_Portrait_Activity
import com.kwad.sdk.api.proxy.app.AdWebViewActivity
import com.kwad.sdk.api.proxy.app.FeedDownloadActivity
import com.octopus.ad.AdActivity
import yyee.llee.mmee.RouteTranInterface
import yyee.llee.mmee.base_api_factory.ModuleConfig
import com.qq.e.ads.PortraitADActivity
import com.qq.e.ads.RewardvideoPortraitADActivity
import java.util.concurrent.ConcurrentHashMap

object AdUtils {
    private var TAG = yyee.llee.mmee.base_api_factory.ModuleConfig.AD_LOG_TAG

    private val mTopActivities = ConcurrentHashMap<Int, Activity>()

    fun isShowAd(key: String): Boolean {
        val size = mTopActivities.size
        Log.e("zdc", "AdUtils isShowAd key:$key,size:$size")
        printActivity()
        return if (true) { //如果需要判断前台
            size <= 0
        } else {
            true
        }
    }

    fun isForeground(): Boolean {
        val b = mTopActivities.size > 0
        Log.d(TAG, "isForeground: $b")
        printActivity()
        return b
    }

    fun add(code: Int, activity: Activity) {
        mTopActivities[code] = activity
    }

    fun remove(code: Int) {
        mTopActivities.remove(code)
    }

    private fun printActivity() {
        mTopActivities.forEach { (t, u) ->
            Log.d(TAG, "--current activity: t:$t, u:$u")
        }
    }


    @JvmStatic
    fun isAdActivity(currAdActivity: Activity?): Boolean {
        return (currAdActivity is RewardvideoPortraitADActivity
                || currAdActivity is Stub_Standard_Portrait_Activity
                || currAdActivity is FeedDownloadActivity
                || currAdActivity is PortraitADActivity
                || currAdActivity is AdWebViewActivity
                || currAdActivity is RouteTranInterface
                || currAdActivity is MobRewardVideoActivity
                || currAdActivity is AdActivity)
    }


}